package org.gy;

import java.util.Arrays;
import java.util.Scanner;

public class ScoreCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double[] scores = new double[7]; // 存储评委的分数

        // 录入7位评委的分数
        for (int i = 0; i < scores.length; i++) {
            double score;
            do {
                System.out.printf("请输入第%d位评委的分数 (1-100): ", (i + 1));
                score = scanner.nextDouble();
                if (score < 1 || score > 100) {
                    System.out.println("分数必须在1到100之间，请重新输入！");
                }
            } while (score < 1 || score > 100);
            scores[i] = score;
        }

        // 对分数进行排序
        Arrays.sort(scores);

        // 去掉一个最高分和一个最低分
        double sum = 0;
        for (int i = 1; i < scores.length - 1; i++) {
            sum += scores[i];
        }

        // 计算平均分
        double average = sum / 5.0;
        System.out.printf("去掉一个最高分和一个最低分后的平均分是: %.2f\n", average);

        scanner.close();
    }
}